//utils.js
 
//因为这个音效听起来是叮的声音，所以我取这个函数名，方便记忆音效，找的合适的场景就能想起来。
function play_ding_success() {
    const innerAudioContext = uni.createInnerAudioContext();
    innerAudioContext.autoplay = true;
    innerAudioContext.src = '/static/radio/success.mp3';
    innerAudioContext.onPlay(() => {
      console.log('开始播放');
    });
    innerAudioContext.onError((res) => {
      console.log(res.errMsg);
      console.log(res.errCode);
    });
    setTimeout(() => {
        innerAudioContext.destroy() // 音效一般为1s，2s后销毁实例
    }, 2000)    
}
function play_ding_fail() {
    const innerAudioContext = uni.createInnerAudioContext();
    innerAudioContext.autoplay = true;
    innerAudioContext.src = '/static/radio/error.mp3';
    innerAudioContext.onPlay(() => {
      console.log('开始播放');
    });
    innerAudioContext.onError((res) => {
      console.log(res.errMsg);
      console.log(res.errCode);
    });
    setTimeout(() => {
        innerAudioContext.destroy() // 音效一般为1s，2s后销毁实例
    }, 2000)    
}
function play_ding_duole() {
    const innerAudioContext = uni.createInnerAudioContext();
    innerAudioContext.autoplay = true;
    innerAudioContext.src = '/static/radio/duole.mp3';
    innerAudioContext.onPlay(() => {
        console.log('开始播放');
    });
    innerAudioContext.onError((res) => {
        console.log(res.errMsg);
        console.log(res.errCode);
    });
    setTimeout(() => {
        innerAudioContext.destroy() // 音效一般为1s，2s后销毁实例
    }, 3000)
}
function play_ding_cuole() {
    const innerAudioContext = uni.createInnerAudioContext();
    innerAudioContext.autoplay = true;
    innerAudioContext.src = '/static/radio/cuole.mp3';
    innerAudioContext.onPlay(() => {
        console.log('开始播放');
    });
    innerAudioContext.onError((res) => {
        console.log(res.errMsg);
        console.log(res.errCode);
    });
    setTimeout(() => {
        innerAudioContext.destroy() // 音效一般为1s，2s后销毁实例
    }, 3000)
}
module.exports = {
    play_ding_success,
    play_ding_fail,
    play_ding_cuole,
    play_ding_duole
}